﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Heaven.Texturing
{
    /// <summary>
    /// Represents a layer format
    /// </summary>
    public abstract class LayerFormat
    {
        /// <summary>
        /// Size in bytes of one pixel
        /// </summary>
        public abstract int ElementSize
        {
            get;
        }

        /// <summary>
        /// Gets data from a layer with 
        /// converting from one format to current
        /// </summary>
        /// <param name="layer">Texture layer</param>
        /// <returns>Data in current format</returns>
        public abstract byte[] GetData(Layer layer);

        /// <summary>
        /// Compares two formats instances for equality
        /// </summary>
        /// <param name="left">The first to compare</param>
        /// <param name="right">The second to compare</param>
        /// <returns>true if the two format objects are equal; otherwise, false</returns>
        public static bool operator ==(LayerFormat left, LayerFormat right)
        {
            object a = left as object;
            object b = right as object;
            if ((a == null)&&(b == null)) return true;
            if (a == null) return false;
            if (b == null) return false;
            return left.GetType() == right.GetType();
        }


        /// <summary>
        /// Compares two formats instances for equality
        /// </summary>
        /// <param name="left">The first to compare</param>
        /// <param name="right">The second to compare</param>
        /// <returns>false if the two format objects are equal; otherwise, true</returns>
        public static bool operator !=(LayerFormat left, LayerFormat right)
        {
            return !(left == right);
        }
    }
}
